{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-01-19T06:31:26.793617600Z",
     "start_time": "2024-01-19T06:31:26.776068900Z"
    }
   },
   "outputs": [],
   "source": [
    "from copy import deepcopy\n",
    "import torch\n",
    "import platform\n",
    "platform = platform.system()\n",
    "if platform == 'Linux':\n",
    "    !BASICSR_JIT=True\n",
    "else:\n",
    "    !set BASICSR_JIT=True\n",
    "\n",
    "from basicsr import get_root_logger\n",
    "\n",
    "\n",
    "def print_different_keys_loading(crt_net, load_net, strict=True):\n",
    "    \"\"\"Print keys with different name or different size when loading models.\n",
    "\n",
    "    1. Print keys with different names.\n",
    "    2. If strict=False, print the same key but with different tensor size.\n",
    "        It also ignore these keys with different sizes (not load).\n",
    "\n",
    "    Args:\n",
    "        crt_net (torch model): Current network.\n",
    "        load_net (dict): Loaded network.\n",
    "        strict (bool): Whether strictly loaded. Default: True.\n",
    "    \"\"\"\n",
    "    crt_net = crt_net.state_dict()\n",
    "    crt_net_keys = set(crt_net.keys())\n",
    "    load_net_keys = set(load_net.keys())\n",
    "\n",
    "    logger = get_root_logger()\n",
    "    if crt_net_keys != load_net_keys:\n",
    "        logger.warning('当前神经网络 相比 已加载的神经网络 多出的网络层:')\n",
    "        for v in sorted(list(crt_net_keys - load_net_keys)):\n",
    "            logger.warning(f'  {v}')\n",
    "        logger.warning('已加载的神经网络 相比 当前神经网络 多出的网络参数层:')\n",
    "        for v in sorted(list(load_net_keys - crt_net_keys)):\n",
    "            logger.warning(f'  {v}')\n",
    "\n",
    "    # check the size for the same keys\n",
    "    if not strict:\n",
    "        common_keys = crt_net_keys & load_net_keys\n",
    "        for k in common_keys:\n",
    "            if crt_net[k].size() != load_net[k].size():\n",
    "                logger.warning(f'网络参数层[{k}]形状不同，以忽略: 当前网络参数层形状: '\n",
    "                               f'{crt_net[k].shape}; 已加载网络参数层形状: {load_net[k].shape}')\n",
    "                load_net[k + '.ignore'] = load_net.pop(k)\n",
    "\n",
    "def load_network(net, load_path, strict=True, param_key='params'):\n",
    "    \"\"\"Load network.\n",
    "\n",
    "    Args:\n",
    "        load_path (str): The path of networks to be loaded.\n",
    "        net (nn.Module): Network.\n",
    "        strict (bool): Whether strictly loaded.\n",
    "        param_key (str): The parameter key of loaded network. If set to\n",
    "            None, use the root 'path'.\n",
    "            Default: 'params'.\n",
    "    \"\"\"\n",
    "    logger = get_root_logger()\n",
    "    load_net = torch.load(load_path, map_location=lambda storage, loc: storage)\n",
    "    if param_key is not None:\n",
    "        if param_key not in load_net and 'params' in load_net:\n",
    "            param_key = 'params'\n",
    "            logger.info('加载中: params_ema（指数滑动平均）不存在，将使用 params')\n",
    "        load_net = load_net[param_key]\n",
    "    logger.info(f'从 {load_path} 加载模型 {net.__class__.__name__} 网络参数层为: [{param_key}].')\n",
    "    # remove unnecessary 'module.'\n",
    "    for k, v in deepcopy(load_net).items():\n",
    "        if k.startswith('module.'):\n",
    "            load_net[k[7:]] = v\n",
    "            load_net.pop(k)\n",
    "    print_different_keys_loading(net, load_net, strict)\n",
    "    net.load_state_dict(load_net, strict=strict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "OrderedDict([('LQ_stage', False), ('frozen_module_keywords', ['quantizer', 'decoder_group', 'after_quant', 'out_conv'])])\n",
      "OrderedDict([('LQ_stage', True), ('frozen_module_keywords', ['quantizer', 'decoder_group', 'after_quant', 'out_conv'])])\n",
      "vq_encoder.in_conv.weight\n",
      "vq_encoder.in_conv.bias\n",
      "vq_encoder.blocks.0.0.weight\n",
      "vq_encoder.blocks.0.0.bias\n",
      "vq_encoder.blocks.0.1.conv.0.norm.weight\n",
      "vq_encoder.blocks.0.1.conv.0.norm.bias\n",
      "vq_encoder.blocks.0.1.conv.2.weight\n",
      "vq_encoder.blocks.0.1.conv.2.bias\n",
      "vq_encoder.blocks.0.1.conv.3.norm.weight\n",
      "vq_encoder.blocks.0.1.conv.3.norm.bias\n",
      "vq_encoder.blocks.0.1.conv.5.weight\n",
      "vq_encoder.blocks.0.1.conv.5.bias\n",
      "vq_encoder.blocks.0.2.conv.0.norm.weight\n",
      "vq_encoder.blocks.0.2.conv.0.norm.bias\n",
      "vq_encoder.blocks.0.2.conv.2.weight\n",
      "vq_encoder.blocks.0.2.conv.2.bias\n",
      "vq_encoder.blocks.0.2.conv.3.norm.weight\n",
      "vq_encoder.blocks.0.2.conv.3.norm.bias\n",
      "vq_encoder.blocks.0.2.conv.5.weight\n",
      "vq_encoder.blocks.0.2.conv.5.bias\n",
      "vq_encoder.blocks.1.0.weight\n",
      "vq_encoder.blocks.1.0.bias\n",
      "vq_encoder.blocks.1.1.conv.0.norm.weight\n",
      "vq_encoder.blocks.1.1.conv.0.norm.bias\n",
      "vq_encoder.blocks.1.1.conv.2.weight\n",
      "vq_encoder.blocks.1.1.conv.2.bias\n",
      "vq_encoder.blocks.1.1.conv.3.norm.weight\n",
      "vq_encoder.blocks.1.1.conv.3.norm.bias\n",
      "vq_encoder.blocks.1.1.conv.5.weight\n",
      "vq_encoder.blocks.1.1.conv.5.bias\n",
      "vq_encoder.blocks.1.2.conv.0.norm.weight\n",
      "vq_encoder.blocks.1.2.conv.0.norm.bias\n",
      "vq_encoder.blocks.1.2.conv.2.weight\n",
      "vq_encoder.blocks.1.2.conv.2.bias\n",
      "vq_encoder.blocks.1.2.conv.3.norm.weight\n",
      "vq_encoder.blocks.1.2.conv.3.norm.bias\n",
      "vq_encoder.blocks.1.2.conv.5.weight\n",
      "vq_encoder.blocks.1.2.conv.5.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.norm1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.norm1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.norm2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.norm2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.0.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn_mask\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.norm1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.norm1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.norm2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.norm2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.1.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.norm1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.norm1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.norm2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.norm2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.2.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn_mask\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.norm1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.norm1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.norm2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.norm2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.3.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.norm1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.norm1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.norm2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.norm2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.4.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn_mask\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.norm1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.norm1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.norm2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.norm2.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.0.residual_group.blocks.5.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.0.conv.weight\n",
      "ridcp_encoder.swin_blks.0.conv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.norm1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.norm1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.norm2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.norm2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.0.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn_mask\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.norm1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.norm1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.norm2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.norm2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.1.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.norm1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.norm1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.norm2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.norm2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.2.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn_mask\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.norm1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.norm1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.norm2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.norm2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.3.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.norm1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.norm1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.norm2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.norm2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.4.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn_mask\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.norm1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.norm1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.norm2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.norm2.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.1.residual_group.blocks.5.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.1.conv.weight\n",
      "ridcp_encoder.swin_blks.1.conv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.norm1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.norm1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.norm2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.norm2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.0.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn_mask\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.norm1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.norm1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.norm2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.norm2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.1.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.norm1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.norm1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.norm2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.norm2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.2.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn_mask\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.norm1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.norm1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.norm2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.norm2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.3.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.norm1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.norm1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.norm2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.norm2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.4.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn_mask\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.norm1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.norm1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.norm2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.norm2.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.2.residual_group.blocks.5.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.2.conv.weight\n",
      "ridcp_encoder.swin_blks.2.conv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.norm1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.norm1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.norm2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.norm2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.0.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn_mask\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.norm1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.norm1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.norm2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.norm2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.1.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.norm1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.norm1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.norm2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.norm2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.2.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn_mask\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.norm1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.norm1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.norm2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.norm2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.3.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.norm1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.norm1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.norm2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.norm2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.4.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn_mask\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.norm1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.norm1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn.relative_position_bias_table\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn.relative_position_index\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn.qkv.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn.qkv.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn.proj.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.attn.proj.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.norm2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.norm2.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.mlp.fc1.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.mlp.fc1.bias\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.mlp.fc2.weight\n",
      "ridcp_encoder.swin_blks.3.residual_group.blocks.5.mlp.fc2.bias\n",
      "ridcp_encoder.swin_blks.3.conv.weight\n",
      "ridcp_encoder.swin_blks.3.conv.bias\n",
      "ridcp_decoder.upsampler.0.1.weight\n",
      "ridcp_decoder.upsampler.0.1.bias\n",
      "ridcp_decoder.upsampler.0.2.conv.0.norm.weight\n",
      "ridcp_decoder.upsampler.0.2.conv.0.norm.bias\n",
      "ridcp_decoder.upsampler.0.2.conv.2.weight\n",
      "ridcp_decoder.upsampler.0.2.conv.2.bias\n",
      "ridcp_decoder.upsampler.0.2.conv.3.norm.weight\n",
      "ridcp_decoder.upsampler.0.2.conv.3.norm.bias\n",
      "ridcp_decoder.upsampler.0.2.conv.5.weight\n",
      "ridcp_decoder.upsampler.0.2.conv.5.bias\n",
      "ridcp_decoder.upsampler.0.3.conv.0.norm.weight\n",
      "ridcp_decoder.upsampler.0.3.conv.0.norm.bias\n",
      "ridcp_decoder.upsampler.0.3.conv.2.weight\n",
      "ridcp_decoder.upsampler.0.3.conv.2.bias\n",
      "ridcp_decoder.upsampler.0.3.conv.3.norm.weight\n",
      "ridcp_decoder.upsampler.0.3.conv.3.norm.bias\n",
      "ridcp_decoder.upsampler.0.3.conv.5.weight\n",
      "ridcp_decoder.upsampler.0.3.conv.5.bias\n",
      "ridcp_decoder.upsampler.1.1.weight\n",
      "ridcp_decoder.upsampler.1.1.bias\n",
      "ridcp_decoder.upsampler.1.2.conv.0.norm.weight\n",
      "ridcp_decoder.upsampler.1.2.conv.0.norm.bias\n",
      "ridcp_decoder.upsampler.1.2.conv.2.weight\n",
      "ridcp_decoder.upsampler.1.2.conv.2.bias\n",
      "ridcp_decoder.upsampler.1.2.conv.3.norm.weight\n",
      "ridcp_decoder.upsampler.1.2.conv.3.norm.bias\n",
      "ridcp_decoder.upsampler.1.2.conv.5.weight\n",
      "ridcp_decoder.upsampler.1.2.conv.5.bias\n",
      "ridcp_decoder.upsampler.1.3.conv.0.norm.weight\n",
      "ridcp_decoder.upsampler.1.3.conv.0.norm.bias\n",
      "ridcp_decoder.upsampler.1.3.conv.2.weight\n",
      "ridcp_decoder.upsampler.1.3.conv.2.bias\n",
      "ridcp_decoder.upsampler.1.3.conv.3.norm.weight\n",
      "ridcp_decoder.upsampler.1.3.conv.3.norm.bias\n",
      "ridcp_decoder.upsampler.1.3.conv.5.weight\n",
      "ridcp_decoder.upsampler.1.3.conv.5.bias\n",
      "ridcp_decoder.warp.0.offset.weight\n",
      "ridcp_decoder.warp.0.offset.bias\n",
      "ridcp_decoder.warp.0.dcn.weight\n",
      "ridcp_decoder.warp.0.dcn.bias\n",
      "ridcp_decoder.warp.0.dcn.conv_offset.weight\n",
      "ridcp_decoder.warp.0.dcn.conv_offset.bias\n",
      "ridcp_decoder.warp.1.offset.weight\n",
      "ridcp_decoder.warp.1.offset.bias\n",
      "ridcp_decoder.warp.1.dcn.weight\n",
      "ridcp_decoder.warp.1.dcn.bias\n",
      "ridcp_decoder.warp.1.dcn.conv_offset.weight\n",
      "ridcp_decoder.warp.1.dcn.conv_offset.bias\n",
      "vq_decoder_group.0.block.1.weight\n",
      "vq_decoder_group.0.block.1.bias\n",
      "vq_decoder_group.0.block.2.conv.0.norm.weight\n",
      "vq_decoder_group.0.block.2.conv.0.norm.bias\n",
      "vq_decoder_group.0.block.2.conv.2.weight\n",
      "vq_decoder_group.0.block.2.conv.2.bias\n",
      "vq_decoder_group.0.block.2.conv.3.norm.weight\n",
      "vq_decoder_group.0.block.2.conv.3.norm.bias\n",
      "vq_decoder_group.0.block.2.conv.5.weight\n",
      "vq_decoder_group.0.block.2.conv.5.bias\n",
      "vq_decoder_group.0.block.3.conv.0.norm.weight\n",
      "vq_decoder_group.0.block.3.conv.0.norm.bias\n",
      "vq_decoder_group.0.block.3.conv.2.weight\n",
      "vq_decoder_group.0.block.3.conv.2.bias\n",
      "vq_decoder_group.0.block.3.conv.3.norm.weight\n",
      "vq_decoder_group.0.block.3.conv.3.norm.bias\n",
      "vq_decoder_group.0.block.3.conv.5.weight\n",
      "vq_decoder_group.0.block.3.conv.5.bias\n",
      "vq_decoder_group.1.block.1.weight\n",
      "vq_decoder_group.1.block.1.bias\n",
      "vq_decoder_group.1.block.2.conv.0.norm.weight\n",
      "vq_decoder_group.1.block.2.conv.0.norm.bias\n",
      "vq_decoder_group.1.block.2.conv.2.weight\n",
      "vq_decoder_group.1.block.2.conv.2.bias\n",
      "vq_decoder_group.1.block.2.conv.3.norm.weight\n",
      "vq_decoder_group.1.block.2.conv.3.norm.bias\n",
      "vq_decoder_group.1.block.2.conv.5.weight\n",
      "vq_decoder_group.1.block.2.conv.5.bias\n",
      "vq_decoder_group.1.block.3.conv.0.norm.weight\n",
      "vq_decoder_group.1.block.3.conv.0.norm.bias\n",
      "vq_decoder_group.1.block.3.conv.2.weight\n",
      "vq_decoder_group.1.block.3.conv.2.bias\n",
      "vq_decoder_group.1.block.3.conv.3.norm.weight\n",
      "vq_decoder_group.1.block.3.conv.3.norm.bias\n",
      "vq_decoder_group.1.block.3.conv.5.weight\n",
      "vq_decoder_group.1.block.3.conv.5.bias\n",
      "out_conv.weight\n",
      "out_conv.bias\n",
      "residual_conv.weight\n",
      "residual_conv.bias\n",
      "quantizer.embedding.weight\n",
      "before_quant.weight\n",
      "before_quant.bias\n",
      "after_quant.conv.weight\n",
      "after_quant.conv.bias\n"
     ]
    }
   ],
   "source": [
    "from collections import OrderedDict\n",
    "from basicsr.utils.registry import ARCH_REGISTRY\n",
    "from basicsr.utils.options import ordered_yaml\n",
    "import yaml\n",
    "from basicsr import build_network\n",
    "from basicsr.archs.ridcp_new_arch import RIDCPNew\n",
    "\n",
    "pretrained_new_hqp_path = \"../pretrained_models/pretrained_HQPs_renamed.pth\"\n",
    "pretrained_new_net_path = \"../pretrained_models/pretrained_RIDCP_renamed.pth\"\n",
    "param_key = 'params'\n",
    "\n",
    "with open(\"../options/RIDCPNew-pei-NH-HAZE.yml\", mode='r') as f:\n",
    "    opt = yaml.load(f, Loader=ordered_yaml()[0])\n",
    "hq_opt = opt['network_g'].copy()\n",
    "hq_opt['LQ_stage'] = False\n",
    "hq_opt_type = hq_opt[\"type\"]\n",
    "hq_opt.pop('type')\n",
    "print(hq_opt)\n",
    "# print(opt[\"network_g\"])\n",
    "# net = build_network(hq_opt)\n",
    "# hqp = build_network(opt['network_g'])\n",
    "\n",
    "# def func(*, LQ_stage, **kwargs):\n",
    "#     print(LQ_stage, kwargs)\n",
    "# func(**hq_opt)\n",
    "# opt_hqp = {\n",
    "#     \"LQ_stage\": False,\n",
    "#     \"frozen_module_keywords\": ['quantizer', 'decoder_group', 'after_quant', 'out_conv']\n",
    "# }\n",
    "opt_net = {\n",
    "    #\"LQ_stage\": True,\n",
    "    \"frozen_module_keywords\": ['quantizer', 'decoder_group', 'after_quant', 'out_conv']\n",
    "}\n",
    "opts = OrderedDict()\n",
    "opts[\"LQ_stage\"] = True\n",
    "opts[\"frozen_module_keywords\"] = ['quantizer', 'decoder_group', 'after_quant', 'out_conv']\n",
    "print(opts)\n",
    "net = ARCH_REGISTRY.get(hq_opt_type)(**opt[\"network_g\"])\n",
    "for key, param in net.state_dict().items():\n",
    "    print(key)\n",
    "    \n",
    "\n",
    "# hqp = ARCH_REGISTRY.get(\"RIDCPNew\")(**opt_hqp)\n",
    "load_network(net, pretrained_new_net_path, True, param_key)\n",
    "# load_network(hqp, pretrained_new_hqp_path, True, param_key)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-01-19T07:19:13.949702100Z",
     "start_time": "2024-01-19T07:19:13.737086900Z"
    }
   },
   "id": "d3f2a13c1d230c7c"
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "bbf7ee4ee5769364"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
